/****************************************************************************
**
****************************************************************************/

#ifndef CARDTHREAD_H
#define CARDTHREAD_H

#include <QThread>

#include "card/abstractCard.h"

class ChargeMain;
class HciMain;

class CardMain : public QThread
{
    Q_OBJECT

public:
    explicit CardMain(QList<ChargeMain *> *chargelist, HciMain *hciMain, QObject *parent = nullptr);
    ~CardMain();

    static QByteArray card_number()
    {
        return card_number_;
    }

    //cmd
    static bool StartChargeService(quint8 gunno);
    static void SetStartChargeService(quint8 gunno);
    static void ClearStartChargeService(quint8 gunno);
    static bool StopChargeService(quint8 gunno);
    static void SetStopChargeService(quint8 gunno);
    static void ClearStopChargeService(quint8 gunno);

protected:
    void run() Q_DECL_OVERRIDE;

private:
    bool m_quit;
    unsigned long m_cycle;

    int current_gun_;
    HciMain *hciMain_ = nullptr;
    QList<ChargeMain *> *chargeMainList_ = nullptr;

    AbstractCard *abstractCard_ = nullptr;

    //cmd - flag
    static QList<bool> start_charge_service_;
    static QList<bool> stop_charge_service_;

    static QByteArray card_number_;

signals:
    void SearchCard();

public slots:
    void HandleCardNumber(QByteArray& card_number);

private slots:

};

#endif // CARDTHREAD_H
